#pragma once

#include <algorithm>

#include "photonMap.h"
#include "texture.h"
#include "pointLight.h"
#include "sphericalLight.h"
#include "areaLight.h"
#include "reflectorLight.h"

#define	SHADING_ALGORITHMS 6

class material
{
public:
	color			ambient;
	color			diffuse;
	color			specular;

	texture			*diffuseMap;
	bool			diffuseMapOrColor;

	double			ambientIntesity;
	double			diffuseIntesity;
	double			specularIntesity;	//between 0.0 and 1.0 1.0 gonna be whole white object 0.0 - 0.1 i safest though
	unsigned int	glosiness;	//between 1 and 100 ... less mean bigger glowing area

	double			refractionCoef;
	double			shadedSurfBalckenssCoef;

	material();
	~material();

	virtual void getMaterialFromXML(std::ifstream &file);

	void setName(const char* namae);
	void setDiffuse(color dif);
	void setAmbient(color amb);
	void setSpecular(color spe);
	bool setTexture(const char* name);

	virtual color getColor(vector3 objNormal, point colisionCoords, vector3 rayDirection, light *Light, bool shade, texcoords texCoords);

	virtual bool reactToPhoton(photon *Photon, vector3 N, point col);
	
	virtual int isSpecial(vector3 *result, vector3 N, vector3 V, point col, double otherN, bool isInside);
	
	material & operator=( material &other );
	
	double saturate(double x);
protected:
	unsigned int shadingAlgorithm; //0- none, 1-lambert, 2-phong, 3-strauss, 4-blinn, 5-metal, 6-oren-nayer-blinn
	
	unsigned int ID;
	std::string	name;
	static int nextMaterialID;

};